###APPENDIX ANALYSIS###

load("data_combined.RData")
load("uk.RData")
load("data2.RData")

###Appendix Tables

### Table E.1
model1<-lm_robust(attitudes_scale~tr_interview+ tr_platform+wave, data=data_combined)
summary(model1)
model1_adj<-lm_robust(attitudes_scale~tr_interview+ tr_platform+wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model1_adj)

model2<-lm_robust(attitudes_scale~tr_interview*tr_platform+wave, data=data_combined)
summary(model2)
model2_adj<-lm_robust(attitudes_scale~tr_interview*tr_platform+wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model2_adj)

model3<-lm_robust(attitudes_scale~factor(tr_cat)+tr_platform, data=uk)
summary(model3)
model3_adj<-lm_robust(attitudes_scale~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model3_adj)

model4<-lm_robust(attitudes_scale~factor(tr_cat)*tr_platform, data=uk)
summary(model3)
model4_adj<-lm_robust(attitudes_scale~factor(tr_cat)*tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model4_adj)

texreg(list(model1, model1_adj, model2, model2_adj,model3, model3_adj, model4, model4_adj), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Extreme right attitudes")

## Table E.3
model5<-lm_robust(norms_scale~tr_platform+tr_interview+wave, data=data_combined)
summary(model5)
model5_adj<-lm_robust(norms_scale~tr_platform+tr_interview+ wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model5_adj)

model6<-lm_robust(norms_scale~tr_platform*tr_interview+wave, data=data_combined)
summary(model6)
model6_adj<-lm_robust(norms_scale~tr_platform*tr_interview+ wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model6_adj)

model7<-lm_robust(norms_scale~factor(tr_cat)+tr_platform, data=uk)
summary(model7)
model7_adj<-lm_robust(norms_scale~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model7_adj)

model8<-lm_robust(norms_scale~factor(tr_cat)*tr_platform, data=uk)
summary(model8)
model8_adj<-lm_robust(norms_scale~factor(tr_cat)*tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model8_adj)

texreg(list(model5, model5_adj, model6, model6_adj,model7, model7_adj, model8, model8_adj), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Extreme right attitudes")


### Table E.4
model9 <- multinom(Cottrell3cat~tr_platform + tr_interview + wave, data=data_combined)
summary(model9)
model9_adj <- multinom(Cottrell3cat~tr_platform + tr_interview + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + wave, data=data_combined)
summary(model9_adj)

model10 <- multinom(Cottrell3cat~tr_platform * tr_interview + wave, data=data_combined)
summary(model10)
model10_adj <- multinom(Cottrell3cat~tr_platform * tr_interview + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + wave, data=data_combined)
summary(model10_adj)

model11 <- multinom(Robinson3cat~factor(tr_cat) + tr_platform, data=uk)
summary(model11)
model11_adj <- multinom(Robinson3cat~factor(tr_cat) + tr_platform + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor(brexit), data=uk)
summary(model11_adj)

model12 <- multinom(Robinson3cat~factor(tr_cat) *tr_platform, data=uk)
summary(model12)
model12_adj <- multinom(Robinson3cat~factor(tr_cat) *tr_platform + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor(brexit), data=uk)
summary(model12_adj)

texreg(list(model9, model9_adj, model10, model10_adj,model11, model11_adj, model12, model12_adj), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Respectability of the extreme right actor")


### All items (Tables E5-8)

## Australia - Table E5
data_combined$attitudes_10=(data_combined$attitudes_1)/10
data_combined$attitudes_20=(data_combined$attitudes_2)/10
data_combined$attitudes_30=(data_combined$attitudes_3)/10
data_combined$attitudes_40=(data_combined$attitudes_4)/10

model1_adj<-lm_robust(attitudes_10~tr_interview+ tr_platform+wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model1_adj)
model2_adj<-lm_robust(attitudes_20~tr_interview+ tr_platform+wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model2_adj)
model3_adj<-lm_robust(attitudes_30~tr_interview+ tr_platform+wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model3_adj)
model4_adj<-lm_robust(attitudes_40~tr_interview+ tr_platform+wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model4_adj)
texreg(list(model1_adj, model2_adj,model3_adj, model4_adj ), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Attitudinal Items- Australia")

## Australia - Table E6
data_combined$norms_10=(data_combined$norms_1)/100
data_combined$norms_20=(data_combined$norms_2)/100
data_combined$norms_30=(data_combined$norms_3)/100
data_combined$norms_40=(data_combined$norms_4)/100

model1_adj<-lm_robust(norms_10~tr_interview+ tr_platform+wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model1_adj)
model2_adj<-lm_robust(norms_20~tr_interview+ tr_platform+wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model2_adj)
model3_adj<-lm_robust(norms_30~tr_interview+ tr_platform+wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model3_adj)
model4_adj<-lm_robust(norms_40~tr_interview+ tr_platform+wave+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data_combined)
summary(model4_adj)
texreg(list(model1_adj, model2_adj,model3_adj, model4_adj ), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Normative Items- Australia")

##UK - Table E7
uk$attitudes_10=(uk$attitudes_1)/10
uk$attitudes_20=(uk$attitudes_2)/10
uk$attitudes_30=(uk$attitudes_3)/10
uk$attitudes_40=(uk$attitudes_4)/10
uk$attitudes_50=(uk$attitudes_5)/10

model1_adj<-lm_robust(attitudes_10~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model1_adj)
model2_adj<-lm_robust(attitudes_20~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model2_adj)
model3_adj<-lm_robust(attitudes_30~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model3_adj)
model4_adj<-lm_robust(attitudes_40~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model4_adj)
model5_adj<-lm_robust(attitudes_50~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model5_adj)

texreg(list(model1_adj, model2_adj,model3_adj, model4_adj,model5_adj ), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Attitudinal Items- UK")

##UK - Table E8
uk$norms_10=(uk$norms_1)/100
uk$norms_20=(uk$norms_2)/100
uk$norms_30=(uk$norms_3)/100
uk$norms_40=(uk$norms_4)/100
uk$norms_50=(uk$norms_5)/100

model1_adj<-lm_robust(norms_10~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model1_adj)
model2_adj<-lm_robust(norms_20~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model2_adj)
model3_adj<-lm_robust(norms_30~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model3_adj)
model4_adj<-lm_robust(norms_40~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model4_adj)
model5_adj<-lm_robust(norms_50~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model5_adj)

texreg(list(model1_adj, model2_adj,model3_adj, model4_adj,model5_adj), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Normative Items- UK")


#F1 Mainstream / trustworthy

#Australia
mean(data2$mainstream, na.rm = T)
sd(data2$mainstream, na.rm = T)
mean(data2$mainstreamYT, na.rm = T)
sd(data2$mainstreamYT, na.rm = T)

mean(data2$trustworthy, na.rm = T)
sd(data2$trustworthy, na.rm = T)
mean(data2$trustworthyYT, na.rm = T) 
sd(data2$trustworthyYT, na.rm = T)

t.test(data2$mainstream, data2$mainstreamYT, paired = TRUE)
t.test(data2$trustworthy, data2$trustworthyYT, paired = TRUE)

#UK
mean(uk$mainstreamSN, na.rm = T)
sd(uk$mainstreamSN, na.rm = T)
mean(uk$mainstreamYT, na.rm = T)
sd(uk$mainstreamYT, na.rm = T)

mean(uk$trustworthySN, na.rm = T)
sd(uk$trustworthySN, na.rm = T)
mean(uk$trustworthyYT, na.rm = T) 
sd(uk$trustworthyYT, na.rm = T)

t.test(uk$mainstreamSN, uk$mainstreamYT, paired = TRUE)
t.test(uk$trustworthySN, uk$trustworthyYT, paired = TRUE)

#Reported in footnote 15: 
mean(data2$mainstreamABC, na.rm = T)
mean(uk$mainstreamBBC, na.rm = T)

#F2 Manipulation check

#Australia

tabyl(data2, treatment, check_content)%>%
  adorn_percentages("row") %>%
  adorn_pct_formatting(digits = 1) %>%
  adorn_ns()

tabyl(data2, treatment, check_platform)%>%
  adorn_percentages("row") %>%
  adorn_pct_formatting(digits = 1) %>%
  adorn_ns()

tabyl(data2, treatment, check)%>%
  adorn_percentages("row") %>%
  adorn_pct_formatting(digits = 1) %>%
  adorn_ns()


#UK

uk$treatment_tab[uk$treatment=="YT Weather"]<-"1. Weather YT"
uk$treatment_tab[uk$treatment=="SN Weather"]<-"2. Weather Sky"
uk$treatment_tab[uk$treatment=="Unchallenged YT Itw"]<-"3. Interv YT"
uk$treatment_tab[uk$treatment=="Unchallenged SN Itw"]<-"4. Interv Sky"
uk$treatment_tab[uk$treatment=="Challenged YT Itw"]<-"5. Chal Interv YT"
uk$treatment_tab[uk$treatment=="Challenged SN Itw"]<-"6. Chal Interv Sky"

tabyl(uk, treatment_tab, check_content)%>%
  adorn_percentages("row") %>%
  adorn_pct_formatting(digits = 1) %>%
  adorn_ns()

tabyl(uk, treatment_tab, check_platform)%>%
  adorn_percentages("row") %>%
  adorn_pct_formatting(digits = 1) %>%
  adorn_ns()

tabyl(uk, treatment_tab, check)%>%
  adorn_percentages("row") %>%
  adorn_pct_formatting(digits = 1) %>%
  adorn_ns()

#G1 Attrition

model_mis_attitudes_adj<-lm_robust(mis_attitudes~tr_interview+ tr_platform + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + wave, data=data_combined)
summary(model_mis_attitudes_adj)

model_mis_attitudes1_adj<-lm_robust(mis_attitudes~factor(tr_cat)+ tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party)+ factor (brexit), data=uk)
summary(model_mis_attitudes1_adj)

model_mis_norms_adj<-lm_robust(mis_norms~tr_interview+ tr_platform + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + wave, data=data_combined)
summary(model_mis_norms_adj)

model_mis_norms1_adj<-lm_robust(mis_norms~factor(tr_cat)+ tr_platform + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor(brexit), data=uk)
summary(model_mis_norms1_adj)

model_mis_actor_adj<-lm_robust(mis_actor~tr_interview+ tr_platform + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + wave, data=data_combined)
summary(model_mis_actor_adj)

model_mis_actor1_adj<-lm_robust(mis_actor~factor(tr_cat)+ tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party)+ factor (brexit), data=uk)
summary(model_mis_actor1_adj)

texreg(list(model_mis_attitudes_adj, model_mis_attitudes1_adj, model_mis_norms_adj, model_mis_norms1_adj,model_mis_actor_adj, model_mis_actor1_adj), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Attrition")


### Models with attention checks

## H1 Extreme right attitudes
model1<-lm_robust(attitudes_scale~tr_interview+ tr_platform, data=data2, subset=data2$attention==1)
summary(model1)
model1_adj<-lm_robust(attitudes_scale~tr_interview+ tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data2, subset=data2$attention==1)
summary(model1_adj)

model2<-lm_robust(attitudes_scale~tr_interview*tr_platform, data=data2, subset=data2$attention==1)
summary(model2)
model2_adj<-lm_robust(attitudes_scale~tr_interview*tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data2, subset=data2$attention==1)
summary(model2_adj)

model3<-lm_robust(attitudes_scale~factor(tr_cat)+tr_platform, data=uk, subset = uk$attention==1)
summary(model3)

model3_adj<-lm_robust(attitudes_scale~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk, subset = uk$attention==1)
summary(model3_adj)

model4<-lm_robust(attitudes_scale~factor(tr_cat)*tr_platform, data=uk, subset = uk$attention==1)
summary(model4)

model4_adj<-lm_robust(attitudes_scale~factor(tr_cat)*tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk, subset = uk$attention==1)
summary(model4_adj)

texreg(list(model1, model1_adj, model2, model2_adj, model3, model3_adj, model4, model4_adj), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Extreme right attitudes: with attention checks")


##H2 Extreme right norms
model5<-lm_robust(norms_scale~tr_interview+ tr_platform, data=data2, subset=data2$attention==1)
summary(model5)
model5_adj<-lm_robust(norms_scale~tr_interview+ tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data2, subset=data2$attention==1)
summary(model5_adj)

model6<-lm_robust(norms_scale~tr_interview*tr_platform, data=data2, subset=data2$attention==1)
summary(model6)
model6_adj<-lm_robust(norms_scale~tr_interview*tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party), data=data2, subset=data2$attention==1)
summary(model6_adj)

model7<-lm_robust(norms_scale~factor(tr_cat)+tr_platform, data=uk, subset = uk$attention==1)
summary(model7)
model7_adj<-lm_robust(norms_scale~factor(tr_cat)+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk, subset = uk$attention==1)
summary(model7_adj)

model8<-lm_robust(norms_scale~factor(tr_cat)*tr_platform, data=uk, subset = uk$attention==1)
summary(model8)

model8_adj<-lm_robust(norms_scale~factor(tr_cat)*tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk, subset = uk$attention==1)
summary(model8_adj)

texreg(list(model5, model5_adj, model6, model6_adj,model7, model7_adj, model8, model8_adj), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Extreme right norms: with attention checks")

##H3 Actor
model9 <- multinom(Cottrell3cat~tr_platform + tr_interview + wave, data=data2, subset=data2$attention==1)
summary(model9)
model9_adj <- multinom(Cottrell3cat~tr_platform + tr_interview + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + wave, data=data2, subset=data2$attention==1)
summary(model9_adj)

model10 <- multinom(Cottrell3cat~tr_platform * tr_interview + wave, data=data2, subset=data2$attention==1)
summary(model10)
model10_adj <- multinom(Cottrell3cat~tr_platform * tr_interview + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + wave, data=data2, subset=data2$attention==1)
summary(model10_adj)

model11 <- multinom(Robinson3cat~factor(tr_cat) + tr_platform, data=uk, subset = uk$attention==1)
summary(model11)
model11_adj <- multinom(Robinson3cat~factor(tr_cat) + tr_platform + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor(brexit), data=uk, subset = uk$attention==1)
summary(model11_adj)

model12 <- multinom(Robinson3cat~factor(tr_cat) *tr_platform, data=uk, subset = uk$attention==1)
summary(model12)
model12_adj <- multinom(Robinson3cat~factor(tr_cat) *tr_platform + factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor(brexit), data=uk, subset = uk$attention==1)
summary(model12_adj)

texreg(list(model9, model9_adj, model10, model10_adj,model11, model11_adj, model12, model12_adj), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Anti-Immigrant Norms")


#H4 Media strategy effects
### Challenged models
model13<-lm_robust(attitudes_scale~challenge_bin+tr_platform, data=uk)
summary(model13)
model13_adj<-lm_robust(attitudes_scale~challenge_bin+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model13_adj)

model14<-lm_robust(norms_scale~challenge_bin+tr_platform, data=uk)
summary(model14)
model14_adj<-lm_robust(norms_scale~challenge_bin+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model14_adj)

model15<-lm_robust(Robinson3cat~challenge_bin+tr_platform, data=uk)
summary(model15)
model15_adj<-lm_robust(Robinson3cat~challenge_bin+tr_platform+ factor(region) + factor(sex) + factor(education) + attitudes_pre_scale + age_num + factor(party) + factor (brexit), data=uk)
summary(model15_adj)

texreg(list(model13, model13_adj, model14, model14_adj,model15, model15_adj), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Challenged effects")


#H5 Respondents who rank Sky News as a mainstream platform (pre-treatment) 
model16 <-lm_robust(attitudes_scale~tr_interview+ tr_platform, data=data, subset=data_combined$mainstream_ind==1)
summary(model16)
model16_adj <-lm_robust(norms_scale~tr_interview+ tr_platform, data=data, subset=data_combined$mainstream_ind==1)
summary(model16_adj)
model17 <- multinom(Cottrell3cat~tr_interview + tr_platform, data=data, subset=data_comnbined$mainstream_ind==1)
summary(model17)

model17_adj <-lm_robust(attitudes_scale~tr_interview+ tr_platform, data=uk, subset=uk$mainstreamSN_ind==1)
summary(model17_adj)
model18 <-lm_robust(norms_scale~tr_interview+ tr_platform, data=uk, subset=uk$mainstreamSN_ind==1)
summary(model18)
model18_adj <-multinom(Robinson3cat~tr_interview+ tr_platform, data=uk, subset=uk$mainstreamSN_ind==1)
summary(model18_adj)

texreg(list(model16,model16_adj, model17, model17_adj, model18, model18_adj), include.ci = FALSE, stars=c(0.001, 0.01, 0.05), caption="Respondents who rank Sky News as a mainstream platform (pre-treatment)")




#Appendix Figures

#Figure C1

data<-read.csv("Survation Australia Survey 2020.csv")

data$treatment<-NA
data$treatment[data$RAND =="BC Sky News"]<- "4.Sky Interview"
data$treatment[data$RAND =="BC Youtube"]<- "3.YT Interview"
data$treatment[data$RAND =="WR Youtube"]<- "1.YT Weather"
data$treatment[data$RAND =="WR Sky News"]<- "2.Sky Weather"

data$Lads_mainstream<-NA
data$Lads_mainstream[data$q4=="The Lads Society is not a mainstream political organisation"]<-0
data$Lads_mainstream[data$q4=="Don't know"]<-0
data$Lads_mainstream[data$q3=="Don't know"]<-0
data$Lads_mainstream[data$q3=="Have not heard of"]<-0
data$Lads_mainstream[data$q4=="The Lads Society is a mainstream political organisation"]<-1 

data$Lads_not_mainstream<-NA
data$Lads_not_mainstream[data$q4=="The Lads Society is not a mainstream political organisation"]<-1
data$Lads_not_mainstream[data$q4=="Don't know"]<-0
data$Lads_not_mainstream[data$q3=="Don't know"]<-0
data$Lads_not_mainstream[data$q3=="Have not heard of"]<-0
data$Lads_not_mainstream[data$q4=="The Lads Society is a mainstream political organisation"]<-0 

data$Lads_dontknow<-NA
data$Lads_dontknow[data$q4=="The Lads Society is not a mainstream political organisation"]<-0
data$Lads_dontknow[data$q4=="Don't know"]<-1
data$Lads_dontknow[data$q3=="Don't know"]<-1
data$Lads_dontknow[data$q3=="Have not heard of"]<-1
data$Lads_dontknow[data$q4=="The Lads Society is a mainstream political organisation"]<-0 

data$large_members<-NA
data$large_members[data$q5=="0 - 999"]<-0
data$large_members[data$q5=="1,000 - 9,999"]<-0
data$large_members[data$q5=="10,000 - 99,999"]<-0
data$large_members[data$q5=="100,000 - 499,999"]<-1
data$large_members[data$q5=="500,000 - 1,000,000"]<-1
data$large_members[data$q5=="Over 1,000,000"]<-1
data$large_members[data$q5=="Don't know"]<-0
data$large_members[data$q3=="Don't know"]<-0
data$large_members[data$q3=="Have not heard of"]<-0

data$small_members<-NA
data$small_members[data$q5=="0 - 999"]<-1
data$small_members[data$q5=="1,000 - 9,999"]<-1
data$small_members[data$q5=="10,000 - 99,999"]<-1
data$small_members[data$q5=="100,000 - 499,999"]<-0
data$small_members[data$q5=="500,000 - 1,000,000"]<-0
data$small_members[data$q5=="Over 1,000,000"]<-0
data$small_members[data$q5=="Don't know"]<-0
data$small_members[data$q3=="Don't know"]<-0
data$small_members[data$q3=="Have not heard of"]<-0

data$dk_members <-NA
data$dk_members[data$q5=="0 - 999"]<-0
data$dk_members[data$q5=="1,000 - 9,999"]<-0
data$dk_members[data$q5=="10,000 - 99,999"]<-0
data$dk_members[data$q5=="100,000 - 499,999"]<-0
data$dk_members[data$q5=="500,000 - 1,000,000"]<-0
data$dk_members[data$q5=="Over 1,000,000"]<-0
data$dk_members[data$q5=="Don't know"]<-1
data$dk_members[data$q3=="Don't know"]<-1
data$dk_members[data$q3=="Have not heard of"]<-1


# Create lads figure

data_subset <- data %>% select(treatment, Lads_mainstream, Lads_not_mainstream, Lads_dontknow, large_members, small_members, dk_members)

# Calculate means and CIs
data_long <- data_subset %>% 
  tidyr::gather(key = "outcome", value = "value", 
                Lads_mainstream, Lads_not_mainstream, Lads_dontknow) %>%
  group_by(treatment, outcome) %>%
  summarize(mean = mean(value), 
            lower_ci = mean - qt(0.975, df = n() - 1) * (sd(value) / sqrt(n())),
            upper_ci = mean + qt(0.975, df = n() - 1) * (sd(value) / sqrt(n())))

# Create plot
fig_lads <- ggplot(data_long, aes(x = treatment, y = mean, fill = outcome)) +
  geom_bar(stat = "identity", position = "dodge", color = "black") +
  geom_errorbar(aes(ymin = lower_ci, ymax = upper_ci), 
                width = 0.2, position = position_dodge(0.9), color = "black") +
  geom_text(aes(label = round(mean, 2)), vjust = -2.0, position = position_dodge(width = 0.9), size = 3) +
  labs(x = "Experimental Condition", y = "Lads Society is a mainstream political organisation") +
  scale_fill_manual(values = c("#2B2B2B", "#808080", "#D3D3D3"),
                    labels = c("dont know Lads Society", "Lads Society is mainstream", "Lads Society is not mainstream")) +
  theme_classic() +
  scale_x_discrete(labels = c("YT Weather", "Sky Weather", "YT Interview", "Sky Interview"))

ggsave("fig_lads.pdf",
       fig_lads,
       width = 8,
       height = 6)


# Create members figure

# Calculate means and CIs
data_long2 <- data_subset %>% 
  tidyr::gather(key = "outcome", value = "value", 
                large_members, small_members, dk_members) %>%
  group_by(treatment, outcome) %>%
  summarize(mean = mean(value), 
            lower_ci = mean - qt(0.975, df = n() - 1) * (sd(value) / sqrt(n())),
            upper_ci = mean + qt(0.975, df = n() - 1) * (sd(value) / sqrt(n())))

# Create plot
fig_members <- ggplot(data_long2, aes(x = treatment, y = mean, fill = outcome)) +
  geom_bar(stat = "identity", position = "dodge", color = "black") +
  geom_errorbar(aes(ymin = lower_ci, ymax = upper_ci), 
                width = 0.2, position = position_dodge(0.9), color = "black") +
  geom_text(aes(label = round(mean, 2)), vjust = -2.0, position = position_dodge(width = 0.9), size = 3) +
  labs(x = "Experimental Condition", y = "Lads Society has many members") +
  scale_fill_manual(values = c("#2B2B2B", "#808080", "#D3D3D3"),
                    labels = c("dont know Lads Society", "Lads Society has over 100,000 members", "Lads Society has less than 100,000 members ")) +
  theme_classic() +
  scale_x_discrete(labels = c("YT Weather", "Sky Weather", "YT Interview", "Sky Interview"))

ggsave("fig_members.pdf",
       fig_members,
       width = 8,
       height = 6)
